@extends('admin.public.header')
@section('title','编辑玩家信息')

@section('listcontent')
    <div class="layui-tab-content">
        
            <form class="layui-form">
                <div class="layui-form layuimini-form">
                    <input type="hidden" name="id" value="{{ $info->id ?? '' }}">
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label required">玩家昵称</label> 
                        <div class="layui-input-block">
                            <input type="text" name="nickname" lay-verify="required" lay-reqtext="玩家昵称不能为空" placeholder="请输入玩家昵称" value="{{ $info->nickname ?? '' }}" class="layui-input layui-disabled" disabled> 
                            <tip>玩家昵称不可修改</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">玩家等级</label> 
                        <div class="layui-input-block">
                            <select name="user_level_id">
                                @foreach($user_level as $v)
                                <option value="{{ $v->id }}" @if($info->user_level_id == $v->id) selected="" @endif>{{ $v->name }}</option>
                                @endforeach
                            </select>
                            <tip>玩家等级关系着玩家权益，请谨慎修改</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">可用余额</label>
                        <div class="layui-input-block">
                            <input type="number" name="money" value="{{$info->money ?? 0 }}" class="layui-input">
                            <tip>修改玩家余额为直接操作数据，请谨慎修改</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">可用积分</label>
                        <div class="layui-input-block">
                            <input type="number" name="integral" value="{{$info->integral ?? 0 }}" class="layui-input">
                            <tip>修改玩家积分为直接操作数据，请谨慎修改</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">手机号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="mobile" value="{{$info->mobile ?? '' }}" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">注册时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="createtime" value="{{ $info->created_at }}" class="layui-input layui-disabled" disabled>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="0" title="禁用" @if($info->status ==  0)checked @endif>
                            <input type="radio" name="status" value="1" title="启用" @if($info->status ==  1)checked @endif>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">是否是分销商</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_distributor" value="0" title="否" @if($info->is_distributor ==  0) checked @endif>
                            <input type="radio" name="is_distributor" value="1" title="是" @if($info->is_distributor ==  1) checked @endif>
                        </div>
                    </div>
                </div>
                <div class="hr-line"></div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit lay-filter="saveBtn">确认保存</button>
                    </div>
                </div>
            </form>
        
    </div>

@endsection

@section('listscript')
    <script type="text/javascript">
        layui.use(['layer','form','laydate'], function () {
            var layer = layui.layer, form = layui.form, $=layui.jquery ,laydate = layui.laydate;
            
            form.on('submit(saveBtn)', function(data){
                var loading = layer.msg('加载中..', {icon: 16,shade: 0.3,time: false});
                $.ajax({
                    url:'/admin/user/edit-detail',
                    type:'post',
                    data: data.field,
                    dataType:"JSON",
                    headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                    success:function(res){
                        layer.close(loading);  //返回数据关闭loading
                        if(res.code == 0){
                            layer.msg(res.msg, {icon: 1},function(){
                                setTimeout('parent.location.reload()',500);
                            });
                        }
                        else{
                            layer.msg(res.msg,{icon: 2});
                        }
                    },
                    error:function(e){
                        layer.close(loading);
                        layer.msg("提交失败",{icon: 2});
                    },
                });
                return false;
            });
        });
    </script>
@endsection

